﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using BLL;
using System.Data;
using System.Web.Services.Protocols;
using Model;

namespace Aliyeye.Car.Net.WebService
{
    /// <summary>
    /// Summary description for Accounts_UsersService
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class Accounts_UsersService : BaseWebService
    {
        private BLL.Accounts_Users Bll = new BLL.Accounts_Users();

        [SoapHeader("soapHeader")]
        [WebMethod(Description = "添加用户")]
        public int Add(Model.Accounts_Users model)
        {
            return Bll.Add(model);
        }

        [SoapHeader("soapHeader")]
        [WebMethod(Description = "更新用户")]
        public bool Update(Model.Accounts_Users model)
        {
            return Bll.Update(model);
        }

        [SoapHeader("soapHeader")]
        [WebMethod(Description = "用户登录")]
        public int CheckLogin(string UserName, string Password)
        {
            int result = Bll.CheckLogin(UserName, Password);
            Guid sessionID = Guid.NewGuid();
            int userID = 0;

            try
            {
                if (result > 0)
                {
                    sessionID = Guid.NewGuid();
                    soapHeader = new SoapHeaderClass(userID, sessionID, null, null);
                    RefreshSoapHeaderList(soapHeader);
                    return result;
                }
                return result;
            }
            catch (Exception ex)
            {
                var soapEX = SoapExceptionHelper.RaiseException("Login", ex.Message, ex.Source, SoapExceptionHelper.FaultCode.Server);
                throw soapEX;
            }
        }

        [SoapHeader("soapHeader")]
        [WebMethod(Description = "更新用户密码")]
        public bool UpdatePass(Model.Accounts_Users model)
        {
            return Bll.UpdatePass(model);
        }

        [SoapHeader("soapHeader")]
        [WebMethod(Description = "删除用户")]
        public bool Delete(int Id)
        {
            return Bll.Delete(Id);
        }

        [SoapHeader("soapHeader")]
        [WebMethod(Description = "获取某个用户")]
        public Model.Accounts_Users GetModel(int UserID)
        {
            return Bll.GetModel(UserID);
        }

        [SoapHeader("soapHeader")]
        [WebMethod(Description = "获取所有用户")]
        public DataSet GetList(string strWhere)
        {
            return Bll.GetList(strWhere);
        }
        [SoapHeader("soapHeader")]
        [WebMethod(Description = "获取所有驾驶员用户")]
        public DataSet GetDriveList(string strWhere)
        {
            return Bll.GetDriveList(strWhere);
        } 
    
          [SoapHeader("soapHeader")]
        [WebMethod(Description = "获取某个驾驶员用户")]
        public Model.Accounts_Users GetDriveModel(int UserID)
        {
            return Bll.GetDriveModel(UserID);
        }

          [SoapHeader("soapHeader")]
          [WebMethod(Description = "获取所有驾驶员用户")]
          public DataSet GetDriveLists(string strWhere)
          {
              return Bll.GetDriveLists(strWhere);
          } 
        
          [SoapHeader("soapHeader")]
          [WebMethod(Description = "判断是否已经存在登入用户名")]
          public bool IsExistUserName(string Username)
          {
              return Bll.IsExistUserName(Username);
          } 

        
    }
}
